'use strict';
module.exports = {
	/**
	 * 此函数名称
	 * @url client/user/pub/test 前端调用的url参数地址
	 * data 请求参数
	 * @params {String} params1  参数1
	 */
	main: async (event) => {
		let {
			data = {}, userInfo, util, originalParam
		} = event;
		let {
			customUtil,
			config,
			pubFun,
			vk,
			db,
			_
		} = util;
		let {
			uid
		} = data;
		let res = {
			code: 0,
			msg: ''
		};
		// 业务逻辑开始-----------------------------------------------------------
		// 可写与数据库的交互逻辑等等


		let fl_data = await vk.baseDao.selects({
			dbName: "daoju_shopcart", // 表名
			getCount: false, // 是否需要同时查询满足条件的记录总数量，默认false
			getMain: true, // 是否只返回rows数据，默认false
			whereJson: {
				user_id: uid
			},
			// 按_id降序 asc 升序 desc 降序 
			sortArr: [{
				name: "_add_time",
				type: "desc"
			}],
			foreignDB: [{
				dbName: 'daoju_merchandise',
				localKey: "merchandise_id", // 主表外键字段名
				foreignKey: "_id", // 副表外键字段名
				fieldJson: {
					_id: false,
					status: false,
					_add_time: false,
					_add_time_str: false,
					classification_id: false,
					classification_name: false,
				},
				as: "merchandiseList"
			}]
		});

		res.data = fl_data

		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}